import numpy as np

def randMatrix(PMD_para):
    PSP_theta = PMD_para["PSP_theta"]
    PSP_phi = PMD_para["PSP_phi"]

    # 泡利矩阵
    Pauli_1 = np.eye(2)
    Pauli_2 = np.array([[0, 1], [1, 0]])
    Pauli_3 = np.array([[0, 1], [-1, 0]])

    PSP_mat_theta = np.cos(PSP_theta) * Pauli_1 - np.sin(PSP_theta) * Pauli_3
    PSP_mat_phi = np.cos(PSP_phi) * Pauli_1 + 1j * np.sin(PSP_phi) * Pauli_2

    # PSP的旋转
    Matrix = np.dot(PSP_mat_theta, PSP_mat_phi)

    return Matrix